const { exec } = require('../db/mysql');

const login = (username, password) => {
    const sql = `select * from users where username='${username}' and password='${password}';`
    return exec(sql).then(users => {
        const user = users[0];
        return user ? {
            username: user.username,
            realname: user.realname
        } : void(0);
    });
};

module.exports = {
    login
}
